package svc

import (
	"friend/internal/config"
	"friend/models"
	"github.com/zeromicro/go-zero/core/stores/sqlx"
)

type ServiceContext struct {
	Config                    config.Config
	Conn                      sqlx.SqlConn
	FriendGroupModel          models.FriendGroupModel
	FriendGroupExtendModel    models.FriendGroupExtendModel
	FriendApplyModel          models.FriendApplyModel
	FriendApplyExtendModel    models.FriendApplyExtendModel
	FriendRelationModel       models.FriendRelationModel
	FriendRelationExtendModel models.FriendRelationExtendModel
}

func NewServiceContext(c config.Config) *ServiceContext {
	conn := sqlx.NewMysql(c.MySQL.DataSource)
	return &ServiceContext{
		Config:                    c,
		Conn:                      conn,
		FriendGroupModel:          models.NewFriendGroupModel(conn, c.Cache),
		FriendGroupExtendModel:    models.NewFriendGroupExtendModel(conn, c.Cache),
		FriendApplyModel:          models.NewFriendApplyModel(conn, c.Cache),
		FriendApplyExtendModel:    models.NewFriendApplyExtendModel(conn, c.Cache),
		FriendRelationModel:       models.NewFriendRelationModel(conn, c.Cache),
		FriendRelationExtendModel: models.NewFriendRelationExtendModel(conn, c.Cache),
	}
}
